package com.wyx.bbs.service;

import com.wyx.bbs.domain.Comment;
import com.wyx.bbs.domain.CommentToUser;
import com.wyx.bbs.domain.ThumbsUp;
import com.wyx.bbs.mapper.CommentMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: Wu YunXia
 * @Description:
 * @Date: Created in 16:38 2021/4/1
 * @Modefied By:
 */
@Service
public class CommentService {

    @Resource
CommentMapper commentMapper;

/**
 * 添加
 * @param comment
 * @return
 */
public int addComment (Comment comment){
        return commentMapper.addComment(comment);
    }

/**
 * 查看
 * @param postId
 * @return
 */
public List<CommentToUser> getByPostId (Integer postId, int uid){
        return commentMapper.getByPostId(postId, uid);
    }

    /**
 * 查看用户全部评论
 * @param
 * @return
 */
public List<Comment> getByUid (int uid){
        return commentMapper.getByUid(uid);
    }

    /**
 *读取评论
 * @param
 * @return
 */
public int readComment (List list){
        return commentMapper.readComment(list);
    }


/**
 * 点赞
 * @return
 */
public int addThumbsUp(ThumbsUp thumbsUp){
    System.out.println("thumbsUp.getIsThumbsUp():"+thumbsUp.getIsThumbsUp());
    if(thumbsUp.getIsThumbsUp()==1){
        thumbsUp.setPlusThumbsUp(1);
    }else{
        thumbsUp.setPlusThumbsUp(-1);
    }
        return commentMapper.addThumbsUp(thumbsUp);
    }


}
